package com.zhang.struts.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

public class LogoutAction extends DispatchAction{
	public ActionForward logoutUser(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            		throws Exception {
		HttpSession session = request.getSession();
		
			if(session!=null)
				session.invalidate();
			
			return mapping.findForward("logout");
	}	
	
	public ActionForward JumpShop(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            		throws Exception {			
			return mapping.findForward("shops");
	}
	
	public ActionForward JumpManager(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            		throws Exception {			
			return mapping.findForward("manager");
	}
	
	public ActionForward JumpWaiter(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            		throws Exception {			
			return mapping.findForward("waiter");
	}
}
